<template>
	<div class="login-container">
		<h3 class="title">系统登录</h3>

		<mu-card class="content">
		
			<mu-card-text>
				<p class="input-container"><mu-icon class="icon" value="account_box" color='#999'/><mu-text-field v-model.trim='user' fullWidth label="账号" labelFloat/></p>
				<p class="input-container"><mu-icon class="icon" value="lock_outline" color='#999'/><mu-text-field v-model.trim='password' fullWidth label="密码" type="password" labelFloat /></p>
				<mu-raised-button primary label="登录" @click='login'  fullWidth/>
				<p class="tip">
					<mu-raised-button @click='setLoginData("admin")' label='账号1 : admin 密码 : 123456'/>
					<mu-raised-button @click='setLoginData("normal")' label='账号2 : normal 密码 : 123456'/>
				</p>
				
			</mu-card-text>
		
		</mu-card>

	</div>
</template>

<script>
export default {
  data () {
    return {
      user: '',
      password: '',
      popupVisible: false,
    }
  },
  methods: {
    login () {

      this.$store
        .dispatch('Login', { 'user': this.user, 'password': this.password })
        .then((res) => {
          this.$store.dispatch('openPopup', { message: res.message })
          this.$router.push({ path: '/' })
        })

    },
    setLoginData (type) {
      this.user = type
      this.password = 123456
    }
  },
}
</script>

<style scoped lang='less'>
.success {
  padding: 4px 20px;
  background: gold;
}
.demo-popup-top {
  width: 100%;
  opacity: 0.8;
  height: 48px;
  line-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 375px;
}
.login-container {
  background: linear-gradient(to right, rgb(57, 106, 252), rgb(41, 72, 255));
  min-height: 100vh;
  padding-top: 100px;
  & > .title {
    color: #eee;
    font-size: 26px;
    font-weight: 400;
    margin: 0px auto 30px auto;
    text-align: center;
    font-weight: bold;
  }
  .content {
    width: 500px;
    margin: 0 auto;
    text-align: center;
    padding: 0 20px;
    p.input-container {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .icon {
        margin: 12px 10px 0 0;
      }
    }

    p.tip {
      padding: 20px 0;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>